#pragma once
/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework Class Library
 * Version 2.00
 * 
 * DNS ATM Address Record Structure
 *      Represents a DNS ATM address (ATMA) record.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
#include "stdafx.h"
using namespace System;
using namespace System::Net;

namespace Adaptive
{
	namespace Network
	{
		namespace Dns
		{
			/// <summary>
			/// Represents a DNS ATM address (ATMA) record.
			/// </summary>
			public value struct DnsATMAddressRecord
			{
			internal:
				/// <summary>
				/// Initializes a new instance of the class from the unmanaged record.
				/// </summary>
				/// <param name="record"> A pointer to a DNS_RECORD structure whose contents are to be copied.</param>
				DnsATMAddressRecord(DNS_RECORD* record)
				{
					int count = 0;
					int length = 0;

					if (record != NULL)
					{
						AddressType = (Byte)record->Data.ATMA.AddressType;
						if (record->Data.ATMA.AddressType == DNS_ATMA_FORMAT_E164)
							length = DNS_ATMA_MAX_ADDR_LENGTH;
						else
							length = DNS_ATMA_AESA_ADDR_LENGTH;

						Address = gcnew array<Byte>(length);
						for(count = 0; count < length; count++)
							Address[count] = (Byte)(record->Data.ATMA.Address[count]);
					}
				}
			public:
				/// <summary>
				/// ATM address format.
				/// </summary>
				/// <value>
				/// Two possible values are DNS_ATMA_FORMAT_E164 or DNS_ATMA_FORMAT_AESA.
				/// </value>
				Byte			AddressType;
				/// <summary>
				/// ATM address.
				/// </summary>
				/// <value>
				/// A byte array containing the address value.
				/// 
				/// For E164, represents a NULL-terminated string of less than DNS_ATMA_MAX_ADDR_LENGTH. 
				/// For AESA, its length is exactly DNS_ATMA_AESA_ADDR_LENGTH.
				/// </value>
				array<Byte>^	Address;

			private:
				/// <summary>
				/// Static constructor.
				/// </summary>
				static DnsATMAddressRecord()
				{
				}

			};
		}
	}
}